﻿<%@ Page Language="C#" MasterPageFile="~/SiteAdmin/MasterPage.master" AutoEventWireup="true" CodeFile="PurchaseManager.aspx.cs" Inherits="PurchaseManager" Title="Untitled Page" %>
<%@ Register Src="GoodItems.ascx" TagName="GoodItems" TagPrefix="uc1" %>
<%@ Register src="../Controls/TipMessage/TipMessage.ascx" tagname="TipMessage" tagprefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="contentPlaceHolderID" Runat="Server">
<uc1:TipMessage ID="tipMessage1" runat="server" Style="width:95%;"/>
<asp:Panel ID="pnlGrid" runat="server" CssClass="centerPanel" Width="95%">
<div class="searchDiv" >
           <table cellspacing="0" class="searchTable">
            <tr>
                <td>
                采购单编号：
                </td>
                <td>
                <asp:TextBox ID="S_PurchaseOrderCode" runat="server" CssClass="smallInput" MaxLength="64" ></asp:TextBox>
                </td>
                <td>
                采购日期：
                </td>
                <td>
                <asp:TextBox ID="S_PurchaseDate" runat="server" onfocus="calendar.ShowCaltable(this, event);" CssClass="smallInput" MaxLength="64" ></asp:TextBox>
                </td>
                <td>
                采购类型：
                </td>
                <td>
                <div class="select"><div><ofcc:DropDownList ID="S_PurchaseType" runat="server"></ofcc:DropDownList></div></div>
                </td>
                <td>
                    &nbsp;&nbsp;<asp:Button ID="btnSearch" runat="server" OnClick="btnSearch_Click" Text=" 查询 "  CssClass="searchButton" />
                </td>
            </tr>
            </table>
     </div>
<div class="webPanelBorder" >
    <div class="webPanelCaption">采购管理</div>
    <div class="webPanelContent">
        <ofcc:GridView ID="gridView" runat="server" AutoGenerateColumns="False" 
            onsplitpageindexchange="gridView_SplitPageIndexChange" 
            OnRowDataBound="gridView_RowDataBound" SplitPageIndex="1" 
            SplitPageStyle="Simple" >
            <Columns>
                <asp:TemplateField HeaderText="选择">
                    <ItemTemplate>
                        <input id="PurchaseOrderID" checked="checked" name="PurchaseOrderID" type="radio" 
                            value='<%#DataBinder.Eval(Container.DataItem,"PurchaseOrderID")%>' />
                        <asp:HiddenField ID = "HiddenField2" runat="server" Value='<%#Eval("PurchaseOrderID") %>' />
                    </ItemTemplate>
                    <HeaderStyle Width="40px" />
                </asp:TemplateField>
                <asp:HyperLinkField DataTextField="PurchaseOrderCode" HeaderText="采购单编号" NavigateUrl="#"/> 
                <asp:BoundField DataField="PurchaseDate" DataFormatString="{0:yyyy-MM-dd}" HtmlEncode="False" HeaderText="采购日期" HtmlEncodeFormatString="False" />
                <asp:BoundField DataField="PurchaseTypeName" HeaderText="采购类型" />
                <asp:BoundField DataField="SupplierID" HeaderText="供应商" />
                <asp:BoundField DataField="UserName" HeaderText="经办人" />
                <asp:BoundField DataField="OrgName" HeaderText="经办部门" /> 
                <asp:BoundField DataField="Status" HeaderText="当前状态" /> 
            </Columns>
        </ofcc:GridView>
     </div>
</div>
<iframe id="ifdown" src="" style="display:none;" runat="server"></iframe>
<div class="webPanelButtonArea">
    <ofcc:LinkButton ID="btnAdd" runat="server" OnClick="btnAdd_Click" CssClass="linkButton" >新建采购单</ofcc:LinkButton>
    <ofcc:LinkButton ID="btnEdit" runat="server" OnClick="btnEdit_Click" CssClass="linkButton" >修改采购单</ofcc:LinkButton>
    <ofcc:LinkButton ID="btnRemove" runat="server"  ConfirmMessage="确定要删除吗?" OnClick="btnRemove_Click" CssClass="linkButton" >删除采购单</ofcc:LinkButton>
    <ofcc:LinkButton ID="btnView" runat="server" OnClick="btnView_Click" CssClass="linkButton" >查看采购单</ofcc:LinkButton>
    <ofcc:LinkButton ID="btnExport" runat="server" OnClick="btnExportPurchase_Click" CssClass="linkButton" >导出采购单</ofcc:LinkButton>
    <ofcc:LinkButton ID="btnCommon" runat="server" OnClick="btnCommonPurchase_Click" CssClass="linkButton" >常用采购单</ofcc:LinkButton>
</div> 
</asp:Panel> 

    
<asp:Panel ID="pnlEdit" runat="server" Width="95%" Visible="false" CssClass="centerPanel">
    <div class="webPanelBorder" >
        <div class="webPanelCaption">采购单信息</div>
        <div class="webPanelContent">
             <table cellspacing="1" class="table">
                <tr>
                    <td class="tableSubjectWidth">采购日期：
                    </td>
                    <td><asp:TextBox ID="P_PurchaseDate" runat="server" onfocus="calendar.ShowCaltable(this, event);" CssClass="shortInput" MaxLength="64" ></asp:TextBox>
                        <ofcc:RequiredField ID="RequiredField1" runat="server" />
                    </td>
                    <td class="tableSubjectWidth">期望到货日期：
                    </td>
                    <td><asp:TextBox ID="P_PurchaseHopeDate" runat="server" onfocus="calendar.ShowCaltable(this, event);" CssClass="shortInput" MaxLength="64" ></asp:TextBox>
                        <ofcc:RequiredField ID="RequiredField3" runat="server" />
                    </td>
                </tr>
                <tr> 
                    <td>采购类型：
                    </td>
                    <td><div class="select"><div><ofcc:DropDownList ID="P_PurchaseType" runat="server" CssClass="smallInput"></ofcc:DropDownList>
                        </div></div><ofcc:RequiredField ID="RequiredField2" runat="server" />
                    </td>
                    <td>供 应 商：
                    </td>
                    <td><asp:TextBox ID="P_SupplierID" runat="server" CssClass="shortInput" MaxLength="64" ></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td>采购单来源：</td>
                    <td><div class="select"><div><ofcc:DropDownList ID="P_PurchaseSource" runat="server" CssClass="smallInput"></ofcc:DropDownList>
                        </div></div><ofcc:RequiredField ID="RequiredField4" runat="server" />
                    </td>
                    <td>任务号：</td>
                    <td><asp:TextBox ID="P_TaskNo" ReadOnly="true" runat="server" CssClass="shortInput" MaxLength="64"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td>经 办 人：</td>
                    <td><asp:TextBox ID="P_LoginName" ReadOnly="true" runat="server" CssClass="shortInput" MaxLength="64"></asp:TextBox>
                    </td>
                    <td>经办部门：</td>
                    <td><asp:TextBox ID="P_Department" ReadOnly="true" runat="server" CssClass="shortInput" MaxLength="64"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td>备    注：</td>
                    <td><asp:TextBox ID="P_Description" runat="server" CssClass="shortInput" MaxLength="64"></asp:TextBox>
                    </td>
                    <td>常用采购单：<ofcc:ToolTip ID="tootiop1" CssClass="tip" runat="server" ToolTip="输入标题后自动保存为常用采购单" /></td>
                    <td>
                    <asp:TextBox ID="P_CommonName" runat="server" CssClass="shortInput" MaxLength="64"></asp:TextBox>(标题)
                    </td>
                </tr> 
                </table>  
        </div>
     </div>    
        <asp:UpdatePanel runat="server" ID="UpdatePanel2">
            <ContentTemplate> 
                 <uc1:GoodItems ID="GoodItems" runat="server" Visible="true"/>
                 <asp:Panel ID="pnlSearchGoodCode" runat="server" Visible=false>
                    <span style="float:left">物料编号:&nbsp;<ofcc:ToolTip CssClass="tip" ToolTip="扫描或者输入编号后按回车"  ID="ToolTip2" runat="server" />
                    &nbsp;&nbsp;<asp:TextBox ID="tbGoodCode" runat="server" CssClass="smallInput"></asp:TextBox></span>
                 </asp:Panel>
            </ContentTemplate>
        </asp:UpdatePanel>
    <div class="webPanelButtonArea">
        <ofcc:LinkButton ID="btnSearchGoodCode" runat="server" OnClick="btnSearchGoodCode_Click" CssClass="linkButton" >扫描物料</ofcc:LinkButton>
        <ofcc:LinkButton ID="btnSelect" runat="server" OnClick="btnSelect_Click" CssClass="linkButton" >选择</ofcc:LinkButton>
        <ofcc:LinkButton ID="btnSave" runat="server" OnClick="btnSave_Click" ConfirmMessage="确定保存采购单吗？" CssClass="linkButton" ValidationGroup="submit">保存</ofcc:LinkButton>
        <ofcc:LinkButton ID="btnCancel" runat="server" OnClick="btnCancel_Click"  CssClass="linkButton">取消</ofcc:LinkButton>
    </div>
<asp:HiddenField ID="hfAddOrEdit" runat="server" />
<asp:HiddenField ID="hfPurchaseOrderID" runat="server" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ControlToValidate="P_PurchaseDate"
    Display="None" ErrorMessage="请选择采购日期" ValidationGroup="submit"></asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="P_PurchaseHopeDate"
    Display="None" ErrorMessage="请选择期望到货日期" ValidationGroup="submit"></asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="P_PurchaseType"
    Display="None" ErrorMessage="请选择采购类型" ValidationGroup="submit"></asp:RequiredFieldValidator>
</asp:Panel>

<asp:Panel ID="Panel1" runat="server" Style="display: none" CssClass="modalPopup" Width="800px">
    <asp:Panel ID="Panel2" runat="server" CssClass="modalPopupHeader">
        <div>&nbsp;&nbsp;&nbsp;<asp:Literal ID="literalModalPopup" runat="server"></asp:Literal></div>
    </asp:Panel>
 <div style="padding:2px; height:450px;"> 
        <asp:UpdatePanel runat="server" ID="UpdatePanel1">
        <ContentTemplate>
        <asp:Panel ID="pnlPurchaseStockIn" runat="server" Visible="true">
           <div class="searchDiv" > 
               <table cellspacing="0" class="searchTable" style="margin-top:10px; margin-left:10px;">
                <tr>
                    <td>
                    采购单编号：
                    </td>
                    <td><asp:TextBox ID="SS_PurchaseOrderCode" runat="server" CssClass="smallInput" MaxLength="64" ></asp:TextBox>
                    </td>
                    <td>
                    采购日期：
                    </td>
                    <td><asp:TextBox ID="SS_PurchaseDate" runat="server" onfocus="calendar.ShowCaltable(this, event);" CssClass="smallInput" MaxLength="64" ></asp:TextBox>
                    </td>
                    <td>
                    采购类型：
                    </td>
                    <td>
                    <div class="select"><div><ofcc:DropDownList ID="SS_PurchaseType" runat="server"></ofcc:DropDownList></div></div>
                    </td>
                    <td>
                        &nbsp;&nbsp;<asp:Button ID="Button1" runat="server" UseSubmitBehavior="false" OnClick="btnPurchaseSearch_Click" Text=" 查询 "  CssClass="searchButton" /> 
                    </td>
                </tr>
                </table> 
           </div> 
        <ofcc:GridView ID="purchaseGridView" runat="server" AutoGenerateColumns="False" 
            onsplitpageindexchange="purchaseGridView_SplitPageIndexChange" OnRowDataBound="purchaseGridView_RowDataBound" onrowdeleting="purchaseGridView_RowDeleting">
            <Columns>
                <asp:TemplateField HeaderText="选择">
                    <ItemTemplate>
                        <asp:HiddenField ID ="HiddenField1" runat="server" Value='<%#Eval("PurchaseOrderID") %>' />
                        <input id="PurchaseOrderID" name="PurchaseOrderID" type="radio" 
                            value='<%#DataBinder.Eval(Container.DataItem,"PurchaseOrderID")%>' />
                    </ItemTemplate>
                    <HeaderStyle Width="40px" />
                </asp:TemplateField>
                <asp:HyperLinkField DataTextField="CommonName" HeaderText="标题" NavigateUrl="#" Target="_blank"/>
                <asp:BoundField DataField="PurchaseOrderCode" HeaderText="采购单编号" />
                <asp:BoundField DataField="PurchaseDate" HeaderText="采购日期" />
                <asp:BoundField DataField="PurchaseTypeName" HeaderText="采购类型" />
                <asp:BoundField DataField="SupplierID" HeaderText="供应商" />
                <asp:BoundField DataField="UserName" HeaderText="经办人" />
                <asp:BoundField DataField="OrgName" HeaderText="经办部门" /> 
                <asp:CommandField ShowDeleteButton="true" DeleteText="删除"/>
            </Columns>
        </ofcc:GridView>  
        </asp:Panel> 
        </ContentTemplate>
        </asp:UpdatePanel>    
   </div>
        <div class="modalPopupFooter">
             <asp:LinkButton ID="btnModalPopupOK" runat="server" 
                OnClientClick="modalPopupHide2()" onclick="btnModalPopupOK_Click" >确定</asp:LinkButton>
             <asp:LinkButton ID="btnModalPopupCancel2" runat="server"  onclick="btnCancel_Click">取消</asp:LinkButton>
             <p style="display:none"><ofcc:LinkButton ID="btnModalPopupNone" 
                runat="server" >None Event</ofcc:LinkButton></p>
        </div>

<asp:HiddenField ID="hfModalPopup" runat="server" />
<ajax:ModalPopupExtender runat="server" ID="modalPopup"    
    PopupControlID="Panel1" 
    PopupDragHandleControlID="Panel2"
    TargetControlID="btnModalPopupNone"
    BackgroundCssClass="modalBackground"
    BehaviorID="modalPopupBehavior2" 
    DropShadow="True"
    >    
</ajax:ModalPopupExtender>
<script type="text/javascript">
    function pageLoad() {
        //$addHandler($get("<%=btnModalPopupCancel2.ClientID.ToString() %>"), 'click', modalPopupHide2);
    }
    
    function modalPopupHide2(ev) {
        //fix firefox        
        $get('<%=Panel1.ClientID.ToString() %>').style.display = "none";
        if($get('<%=Panel1.ClientID.ToString() %>_DropShadow')!= null)
            $get('<%=Panel1.ClientID.ToString() %>_DropShadow').style.display = "none";
        var divList = $$('div.modalBackground');
        divList[0].style.display = "none";
        if(ev)
            ev.preventDefault();        
        var modalPopupBehavior2 = $find('modalPopupBehavior2');
        modalPopupBehavior2.hide();
    } 
</script>
</asp:Panel>
<asp:ValidationSummary ID="ValidationSummary1" runat="server" EnableViewState="False"
    ShowMessageBox="True" ShowSummary="False" ValidationGroup="submit" />
</asp:Content>

